<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CtrlC</title>
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="//cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body>
<?php
	if (isset($_POST['code']) and isset($_POST['content'])){
		 $db_code = base64_encode($_POST['code']);
		$contetnt = base64_encode($_POST['content']);
		
		require('connect.php');
			if($db=connect()){
				try{
					$sql = 'REPLACE  INTO `clipboard` (`Y3RybA`, `Y29udGVudA`, `dGltZQ`) VALUES ("'.$db_code.'", "'.$contetnt.'", CURRENT_TIMESTAMP)' ;
					
					$e = $db->prepare($sql);
					$e->execute();
					
						
				}catch(Exception $e){
					
					?> <script>alert("EXM I don't know what happend!")</script><?php
				}
				
				
				?> <script>alert('to ctrv.test4us.top get your content! Code:<?php echo $_POST['code'] ?>')</script><?php
			}else{
				?> <script>alert("EXM I don't know what happend!")</script><?php
			}

	}
		$chars = array( 'A', 'B', 'C', 'D', 
'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L','M', 'N', 'O', 
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y','Z', 
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); 
	
	$Code = $chars[rand(0,35)].$chars[rand(0,35)].$chars[rand(0,35)].$chars[rand(0,35)];
	
	
	
	?>

	<div class="container" style="margin-top:9%;">
  		<div class="jumbotron">
        <div class="panel panel-success">
        <div class="panel-heading"><h1><legend align="center">Ur content get Code:<?php echo $Code ?> </legend></h1>
			<form method="post" onsubmit="return purify()"><input name='code' type=hidden value="<?php echo $Code ?>">
			<input type="hidden" name="content" id="content">
				
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">textarea</label>
    <div class="layui-input-block">
      <textarea id="text" placeholder="content you need to ctrl+c" class="layui-textarea" style="width: 100%"></textarea>
    </div>
  </div>
				
 

		<div>
				<div class="layui-upload">
	  <button type="button" class="layui-btn layui-btn-warm" id="test8" style="width: 50%">ChooseFile</button>
	  <button type="button" class="layui-btn" id="test9" style="width: 49%">Begin upload</button>
	</div>
	
	<div class="layui-upload-drag" id="test10" style="width:100%;">
	  <i class="layui-icon"></i>
	  <p>Click to choose，or drag here!</p>
	</div>

					</div>	<div>
				
				<button type="submit" class="layui-btn layui-btn-normal"  style="width: 100%">CtrlC</button>
				</div>
			</form>
			
				
			<br/>
		</div>
			
        </div>
          <p><h3>Your Mobile clipboard</h3></p>
          <p><li>CtrlC webSite only provide text content in the beta0 </li></p>
          <p><li>The textCode might be other's if you are not luuck </li></p>
          <p><li>Let's us wait for next version</li></p>
          <p><li>We are prepare provide free service for everyOne</li></p>
          <p><li>You are more handsome/beatiful if you donate us</li></p>
        </div>
	</div>
</body>
<script src="./layui/layui.js"></script>
<script>
	function log(str){
		console.log(str)
	}
	function purify(){
		text = $("#text").val()
		log(text)
		$("#content").val(text)
		
		
		if(text) return true
		return false
	}
	
	
	layui.use('upload',function(){
			 
			var upload = layui.upload; //得到 upload 对象
 console.log(upload)
  //选完文件后不自动上传
  upload.render({
    elem: '#test8'
    ,url: '/upload/'
    ,auto: false
    //,multiple: true
    ,bindAction: '#test9'
    ,done: function(res){
      console.log(res)
    }
  });
  
  //拖拽上传
  upload.render({
    elem: '#test10'
    ,url: '/upload/'
    ,done: function(res){
      console.log(res)
    }
  }); 
			 
			 
			 
			 })

     


</script>
</html>